<?php
	require_once "mail/class.phpmailer.php";
class sendmail
{
	private $username;
	private $password;
	private $host;
	private $mail;
	public function __construct($username=null,$password=null,$host=null)
	{
		$this->username = empty($username) ? 'max_fine2' : $username;
		$this->password = empty($password) ? 'i1fine_any' : $password;
		$this->host 	= empty($host)	   ? 'smtp.163.com' : $host;
		$this->mail = new PHPMailer();
		$this->mail->IsSMTP();
		$this->mail->CharSet = 'utf-8';
		$this->mail->Host = $this->host;
		$this->mail->Port = 25;
		$this->mail->SMTPDump = 2;
		$this->mail->Username = $this->username;
		$this->mail->Password = $this->password;
		$this->mail->SMTPAuth = true;
	}
	

	/**
	  发送邮件的函数
	 @param mailto 发送到的地址
	 @param $title 	标题
	 @param $content 内容
	 @param $from 来自于 ***@**.com
	 @param $fromname 显示的名字
	  **/
	public function send($mailto,$title,$content,$fromname,$from = "max_fine2@163.com" )
	{
		$this->mail->From = $from;
		$this->mail->FromName = $fromname;
		$this->mail->AddAddress($mailto);
		$this->mail->Subject = $title;
		$this->mail->Body = $content;
		$this->mail->IsHTML(true);
		$this->mail->AltBody = substr($content,0,200);
		return $this->mail->Send();
	}

}
